<!-- CustomDialog.vue -->
<template>
	<div v-if="visible" class="custom-dialog-overlay" @click="closeDialog">
		<div class="custom-dialog" @click.stop>
			<div class="dialog-header">
				<span class="title">{{ title }}</span>

			</div>
			<div class="dialog-body">
				<slot></slot>
			</div>
			<view class="close-button" @click="closeDialog">
				<view class="">
					X
				</view>
			</view>
		</div>

	</div>
</template>

<script>
	export default {
		props: {
			title: {
				type: String,
				default: '提示',
			},
			visible: {
				type: Boolean,
				default: false,
			},
		},
		methods: {
			closeDialog() {
				this.$emit('update:visible', false);
			},
		},
	};
</script>

<style scoped lang="scss">
	.custom-dialog-overlay {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		background: rgba(0, 0, 0, 0.5);
		display: flex;
		justify-content: center;
		align-items: center;
		z-index: 9999999999999;

		.title {
			font-size: 20px;
			text-align: center;
			margin: auto;
			font-weight: bold;
			margin-bottom: 20px;
		}
	}

	.custom-dialog {
		background: white;
		padding: 20px;
		border-radius: 8px;
		width: 75%;
		height: 65%;
		box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
		display: flex;
		flex-direction: column;


	}

	.dialog-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 10px;
	}

	.close-button {
		background: none;
		border: none;
		font-size: 26px;
		cursor: pointer;
		margin: auto;
		position: relative;

		view {
			position: absolute;
			text-align: center;
			bottom: -40px;
			border-radius: 50%;
			width: 100rpx;
			height: 100rpx;
			line-height: 100rpx;
			background-color: #fff;
			transform: translate(-50%);
		}
	}

	.dialog-body {
		flex: 1;
		overflow-y: auto;
		text-indent: 2em;
	}
</style>